package edu.hawaii.halealohacli.command;

import java.util.ArrayList;
import java.util.List;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * A helper class for set-baseline.
 * @author Calvin
 *
 */

public class Baseline {

  private String source = "";
  private XMLGregorianCalendar date = null;
  private List<Double> list = null;
  
  
  /**
   * Baseline constructor that initializes the variables.
   * @param source WattDepot source
   * @param date XMLGregorianCalendar date
   */
  public Baseline(String source, XMLGregorianCalendar date) {
    this.source = source;
    this.date = date;
    list = new ArrayList<Double>();
  }
  
  /**
   * Adds a baseline to the list.
   * @param power power consumed in watts
   */
  public void addBaseline(double power) {
    list.add(power);
  }
  
  /**
   * Returns the baseline at this hour.
   * @param hour beginning of the hour
   * @return double baseline in watts
   */
  public double getBaseline(int hour) {
    return list.get(hour);
  }
  
  /**
   * Sets the baseline at this hour.
   * @param hour beginning of the hour
   * @param baseline power consumed in watts
   */
  public void setBaseline(int hour, double baseline) {
    list.set(hour, baseline);
  }
  
  /**
   * Returns the source string.
   * @return source string name
   */
  public String getSource() {
    return source;
  }
  
  /**
   * Returns the date as an XMLGregorianCalendar.
   * @return XMLGregorianCalendar the date the baseline is set to
   */
  public XMLGregorianCalendar getDate() {
    return date;
  }
  
  /**
   * get the baseline list. 
   * @return a list.
   */
  public List<Double> getList () {
    return this.list;
  }
}
